//
//  addressEditCell.m
//  LoveFreshBeen
//
//  Created by 胡不归是大虾 on 2016/10/21.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "addressEditCell.h"
@interface addressEditCell( )<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UILabel *markLable;
@property (weak, nonatomic) IBOutlet UITextField *infoTextFiled;


@end
@implementation addressEditCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.infoTextFiled.delegate = self;
    [self.infoTextFiled addTarget:self action:@selector(textFieldDidChangeValue) forControlEvents:UIControlEventEditingChanged];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setRow:(NSInteger)row{
    _row = row;
    switch (row) {
        case 0:
            self.markLable.text = @"联系人";
            self.infoTextFiled.placeholder = @"收货人姓名";
            break;
        case 2:
            self.markLable.text = @"手机号码";
            self.infoTextFiled.placeholder = @"鲜蜂虾联系你的电话";
            break;
        case 3:
            self.markLable.text = @"所在城市";
            self.infoTextFiled.placeholder = @"请选择城市";
            break;
        case 4:
            self.markLable.text = @"所在地区";
            self.infoTextFiled.placeholder = @"请选择你的住宅,大厦,或学校";
            break;
        case 5:
            self.markLable.text = @"详细地址";
            self.infoTextFiled.placeholder = @"请输入楼号门牌号等详细地址";
            break;
        default:
            break;
    }
}

-(void)textFieldDidChangeValue{
    switch (self.row) {
        case 0:
            self.model.accept_name = self.infoTextFiled.text;
            break;
        case 2:
            self.model.telphone = self.infoTextFiled.text;
            break;
        case 3:
            self.model.city_name = self.infoTextFiled.text;
            break;
        case 4:
            self.model.district_name = self.infoTextFiled.text;
            break;
        case 5:
            self.model.address = self.infoTextFiled.text ;
            break;
        default:
            break;
    }
}

-(void)setModel:(MyAdressModel *)model{
    _model = model;
    if (model.accept_name != nil) {
        switch (self.row) {
            case 0:
                self.markLable.text = @"联系人";
                self.infoTextFiled.text = model.accept_name;
                break;
            case 2:
                self.markLable.text = @"手机号码";
                self.infoTextFiled.text = model.telphone;
                break;
            case 3:
                self.markLable.text = @"所在城市";
                self.infoTextFiled.text = model.city_name;
                break;
            case 4:
                self.markLable.text = @"所在地区";
                self.infoTextFiled.text = model.district_name;
                break;
            case 5:
                self.markLable.text = @"详细地址";
                self.infoTextFiled.text = model.address;
                break;
            default:
                break;
        }
    }
}




@end
